﻿#include "QSettingBase.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
QSettingBase::QSettingBase(QWidgetBase *parent) : QWidgetWindowBase(parent)
{

}


QSettingBase::~QSettingBase()
{
	
}

void QSettingBase::initUI()
{
	QWidgetWindowBase::initUI();
	//超时定时器
	m_pQTimer = new QTimer(this);

}

//初始化信号关联
void QSettingBase::initConnect()
{
	QWidgetWindowBase::initConnect();
	connect(m_pQTimer, SIGNAL(timeout()), this, SLOT(slotsTimerOut()));
}

// 启动
void QSettingBase::onStart()
{
	QWidgetWindowBase::onStart();
	// 重置定时器
	timeReset();
	this->setFocus();
}

// 停止
void QSettingBase::onStop()
{
	QWidgetWindowBase::onStop();
	timeStop();
}

// 获取页面超时（默认不超时）
int QSettingBase::getTimeOut()
{
	return -1;
}

// 重置超时
void QSettingBase::timeReset()
{
	int timeOut = getTimeOut();
	if(timeOut > 0)
		m_pQTimer->start(getTimeOut() * 1000);
}

// 停止定时器
void QSettingBase::timeStop()
{
	m_pQTimer->stop();
}

// 超时回调
void QSettingBase::slotsTimerOut()
{
	qDebug("QSettingBase::slotsTimerOut");
}

//窗口大小发生变化自动调用虚函数
void QSettingBase::resizeEvent(QResizeEvent *event)
{
	QWidgetWindowBase::resizeEvent(event);
}
